<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<title>体检预约</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/weui.css">
 <script type="text/javascript" src="js/jquery-2.0.0.min.js"></script>
 <script type="text/javascript" src="js/utile.js"></script>
        <script type="text/javascript">
$(document).ready(function(){
  $(".btInp").mousedown(function(){
    $(this).css("border","1px solid #30a5ff");
  });
   $(".btInp").mouseout(function(){
    $(this).css("border","1px solid #c9c9c9");
  });
   $(".orderBtn").hide();
   var url1 = getURL() + "/mobile/checkIsAble";
	  $.ajax({
		  type: 'POST',
		  url: url1,
		  data: {},
		  success: function(data){
			if(data.isAble){
				$(".levelupBtn").show();
				 var url = getURL() + "/mobile/tofamily";
				  var pram = {};
				  $.ajax({
					  type: 'POST',
					  url: url,
					  data: pram,
					  success: function(data){
						  if(data.canAdd){
								$(".freeBtn").show();
							} else {
								$(".freeBtn").hide();
							}
					  },
					  dataType: "json"
					});
			} else {
				$(".freeBtn").hide();
				$(".levelupBtn").hide();
			}
		  },
		  dataType: "json"
		});
	  refresh();
	  
	 
   
});

function refresh(){
	 var url = getURL() + "/mobile/getOrderList?orderType=2";
	  var pram = {};
	  $.ajax({
		  type: 'POST',
		  url: url,
		  data: pram,
		  success: function(data){
			  
			  $(".supp").text("");// 清空数据
			  for(var i=0;i<data.length;i++){
				  var supp = data[i];
				  var str = '<table width="100%" border="0" class="baseTable" style="border-bottom:1px solid #bababa;padding-bottom:10px;">';
				  if(supp.orderId) {
					  str += '<tr><td>证件号</td><td>'+ supp.idenCardNum+'</td></tr><tr><td>姓名</td><td>'+ supp.empName+'</td></tr><tr><td>性别</td><td>'+ (supp.sex=="1"?"男":"女")+'</td></tr><tr><td>电话</td><td>'+ supp.telephone+'</td></tr><tr><td>邮箱</td><td>'+ (supp.email?supp.email:"")+'</td></tr><tr><td>婚姻状态</td><td>'+ (supp.isMarried=="1"?"已婚":"未婚")+'</td></tr><tr><td width="25%"></td><td width="75%"><a onclick="preview('+supp.orderId+')" class="weui_btn weui_btn_mini weui_btn_plain_blue fr mt10">查看详细</a></td></tr> ';
				  } else {
					  str += '<tr><td width="25%">已选套餐:</td><td width="75%">'+ supp.comboName+'-'+supp.itemName+'</td></tr><tr><td width="25%"><a onclick="buyagain('+supp.orderComboId+')" class="weui_btn weui_btn_mini weui_btn_plain_blue fr mt10">去支付</a></td><td width="25%"><a onclick="cancleUp('+supp.orderComboId+')" class="weui_btn weui_btn_mini weui_btn_plain_blue fr mt10">取消购买</a></td></tr>';
				  }
				  str += '</table>';
				  $(".supp").append(str);
			  }
		  },
		  dataType: "json"
		});
}
   function order(){  
	  window.location.href = "order.html?type=2";
   }
   function levelup(){  
	   alert("请在网页端操作升级或购买");
	  //window.location.href = "buyfamily.html";
   }
   
   function cancleUp(orderComboId){
	   var url = getURL() + "/mobile/cancleUp?orderComboId=" + orderComboId;
		  var pram = {};
		  $.ajax({
			  type: 'POST',
			  url: url,
			  data: pram,
			  success: function(data){
				  if(data.success){
					  alert("取消购买成功");
					  refresh();
				  }
			  },
			  dataType: "json"
			});
	}
   function buyagain(orderComboId){
	   alert("请在网页端操作升级或购买");
	   //window.location.href = getURL() + "/mobile/buyagain?orderComboId=" + orderComboId;
	}
   function preview(orderComboId){
	   window.location.href = "preview.html?type=2&&orderId="+orderComboId;
	}
</script>
</head>

<body >
<header id="header" class="mui-bar mui-bar-nav"> <a onclick="history.go(-1)" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color:#fff;"></a>
  <h1 class="mui-title">家属预约</h1>
</header>
<div class="container" >
<div style="border-bottom:1px solid #bababa;padding-bottom:10px;">
  <p>以下是您的个人资料及条件预约信息...</p>
  <div class="button_sp_area"> <a class="weui_btn weui_btn_mini weui_btn_plain_blue levelupBtn" display="none"  onclick="levelup()">购买</a> <a  onclick="order()" class="weui_btn weui_btn_mini weui_btn_plain_blue freeBtn" style="margin:0;">新增预约</a> </div>
  </div>
  <div class="clear"></div>
  <div width="100%" class="supp">

  
</div>
  
  
</div>
</body>
</html>